﻿using System;
using HarmonyLib;
using UnityEngine;

namespace zrgMod;

public partial class Plugin
{
    [HarmonyPrefix, HarmonyPatch(typeof(NPCEx), "SuoQuChangeShengWang")]
    public static void NPCEx_SuoQuChangeShengWang_Prefix(ref int shengWang)
    {
        // 玩家拥有天赋【诡秘莫测】：声望降低倍率*0.3
        if (PlayerEx.HasTianFu(690261))
        {
            if (shengWang < 0)
            {
                shengWang = (int)Mathf.Floor(Convert.ToSingle(shengWang) * 0.3f);
            }
        }
    }

    [HarmonyPrefix, HarmonyPatch(typeof(Fungus.setMenPaiHaoGanDu), "OnEnter")]
    public static void Fungus_setMenPaiHaoGanDu_OnEnter_Prefix(Fungus.setMenPaiHaoGanDu __instance)
    {
        // 玩家拥有天赋【诡秘莫测】：声望降低倍率*0.3
        if (PlayerEx.HasTianFu(690261))
        {
            int value = Traverse.Create(__instance).Field("Value").GetValue<int>();
            if (value < 0)
            {
                Traverse.Create(__instance).Field("Value").SetValue((int)Mathf.Floor(Convert.ToSingle(value) * 0.3f));
            }
        }
    }
}
